package com.chen.stopwatch.views;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.widget.Button;

import com.chen.stopwatch.R;

public class ToolBarItem {
	Button _button = null;

	Context _context = null;

	int _buttonImageHeight = 0;

	int itemId = -1;

	public ToolBarItem(Context context) {
		_context = context;
		_button = new Button(context);
		_button.setTag(this);
		_button.setBackgroundColor(Color.TRANSPARENT);
		_buttonImageHeight = (int) (_context.getResources()
				.getDimensionPixelSize(R.dimen.navigation_bar_height) * 0.45);
		_button.setTextColor(Color.WHITE);
		_button.setTextSize(10);
	}

	public Button getButton() {
		return _button;
	}

	public void setDrawableRes(int resId) {
		Drawable img = _context.getResources().getDrawable(resId);
		if (null == img)
			return;

		img.setBounds(0, 0, _buttonImageHeight, _buttonImageHeight);
		_button.setCompoundDrawables(null, img, null, null);
	}

	public void setTextId(int resId) {
		_button.setText(resId);
	}

	public void setItemId(int id) {
		itemId = id;
	}

	public int getItemId() {
		return itemId;
	}
}
